Skip to content

feat(outputs.mqtt): Add websocket URI support#18958

Closed
aitorhh wants to merge 1 commit into
influxdata:masterfrom
aitorhh:feat/mqtt-output-websocket-support
Closed

feat(outputs.mqtt): Add websocket URI support#18958
aitorhh wants to merge 1 commit into
influxdata:masterfrom
aitorhh:feat/mqtt-output-websocket-support

Conversation

@aitorhh
Copy link
Copy Markdown

@aitorhh aitorhh commented May 21, 2026

Summary

Adds WebSocket (ws://) and WebSocket Secure (wss://) transport support to the MQTT output plugin.

Motivation

Many MQTT brokers (e.g., cloud-hosted or behind ingress controllers) only expose WebSocket endpoints. The MQTT input plugin (mqtt_consumer) already supports ws:// — this brings parity to the output.

Changes

  • plugins/common/mqtt/mqtt_v3.go — preserve ws/wss schemes instead of overriding to tls
  • plugins/common/mqtt/mqtt_v5.go — same fix for the v5 client
  • plugins/outputs/mqtt/sample.conf — document ws:// and wss:// in the scheme list

Notes

The underlying paho.mqtt.golang library already supports WebSocket transport — this change simply passes the scheme through correctly.

Example config

[[outputs.mqtt]]
  servers = ["wss://broker.example.com:443"]
  topic = 'metrics/{{ .Tag "host" }}'
  username = "user"
  password = "${MQTT_TOKEN}"
  insecure_skip_verify = true
  keep_alive = 30
  data_format = "json"

The MQTT output plugin now supports WebSocket connections by preserving
ws:// and wss:// URL schemes instead of overriding them to tls://.

The underlying paho.mqtt.golang library already supports WebSocket
transport - this change simply passes the scheme through correctly.

This enables publishing to MQTT brokers that only expose WebSocket
endpoints (e.g. wss://broker.example.com:443).
@telegraf-tiger
Copy link
Copy Markdown
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger Bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label May 21, 2026
@telegraf-tiger
Copy link
Copy Markdown
Contributor

@srebhan srebhan changed the title feat(mqtt output): add ws:// and wss:// scheme support feat(outputs.mqtt): Add websocket URI support May 26, 2026
@telegraf-tiger telegraf-tiger Bot added area/mqtt plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels May 26, 2026
@srebhan
Copy link
Copy Markdown
Member

srebhan commented May 26, 2026

@aitorhh please restore the PR description template, especially the AI section, and sign the CLA as we cannot review your PR otherwise.

@srebhan srebhan added the waiting for response waiting for response from contributor label May 26, 2026
@srebhan srebhan self-assigned this May 26, 2026
@aitorhh aitorhh closed this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/mqtt feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins waiting for response waiting for response from contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants